﻿<Window x:Class="Main"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="ATS Next Gen" 
        MinHeight="500" 
        Height="500" 
        MinWidth="500"                 
        Name="ATSMainWindow"
        WindowStartupLocation="CenterScreen" FontFamily="verdana"
        xmlns:locala="clr-namespace:ATS">
    <Window.Resources>      
        <LinearGradientBrush x:Key="NormalBrush" StartPoint="0,0" EndPoint="0,1">
                <GradientStop Color="Red" Offset="0.0"/>
                <GradientStop Color="Red" Offset="1.0"/>
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="NormalBorderBrush" StartPoint="0,0" EndPoint="0,1">
                <GradientStop Color="Black" Offset="0.0"/>
                <GradientStop Color="Gray" Offset="1.0"/>
            </LinearGradientBrush>
            <SolidColorBrush x:Key="GlyphBrush" Color="Black" />
            <LinearGradientBrush x:Key="HoverBrush" StartPoint="0,0" EndPoint="0,1">
                <GradientStop Color="Gray" Offset="0.0"/>
                <GradientStop Color="LightGreen" Offset="1.0"/>
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
                <GradientStop Color="Red" Offset="0.0"/>
                <GradientStop Color="#404040" Offset="0.1"/>
                <GradientStop Color="#707070" Offset="0.9"/>
                <GradientStop Color="#808080" Offset="1.0"/>
            </LinearGradientBrush>
            <SolidColorBrush x:Key="ForegroundBrush" Color="Black" />
            <LinearGradientBrush x:Key="HeaderBrush" StartPoint="0,0" EndPoint="0,1">
                <GradientStop Color="White" Offset="0"/>
                <GradientStop Color="LightGray" Offset="1"/>
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="OpenHeaderBorderBrush" StartPoint="0,0" EndPoint="0,1">
                <GradientStop Color="Gray" Offset="0.0"/>
                <GradientStop Color="Black" Offset="1.0"/>
            </LinearGradientBrush>
            <SolidColorBrush x:Key="GroupBackgroundBrush" Color="Transparent"/>
            <SolidColorBrush x:Key="OpenGroupBorderBrush" Color="#808080"/>
            <SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#404040" />
            <SolidColorBrush x:Key="DisabledBorderBrush" Color="#606060" />
            <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#808080" />

            <!-- Expander toogle button template -->
            <ControlTemplate x:Key="ExpanderToggleButton" TargetType="ToggleButton">
                <Border Name="Border"
                        CornerRadius="20"
                        Margin="2,4" 
                        Background="Transparent"
                        BorderBrush="{StaticResource NormalBorderBrush}"
                        BorderThickness="1">
                    <Path Name="Arrow"
                          Fill="{StaticResource GlyphBrush}"
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center"
                          Data= "M 0 0 L 4 4 L 8 0 Z"/>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="ToggleButton.IsMouseOver" Value="true">
                        <Setter TargetName="Border" Property="Background"
                                Value="{StaticResource HoverBrush}" />
                    </Trigger>
                    <Trigger Property="IsPressed" Value="true">
                        <Setter TargetName="Border" Property="Background"
                                Value="{StaticResource PressedBrush}" />
                    </Trigger>
                    <Trigger Property="IsChecked" Value="true">
                        <Setter TargetName="Arrow" Property="Data"
                                Value="M 0 4 L 4 0 L 8 4 Z" />
                    </Trigger>
                    <Trigger Property="IsEnabled" Value="False">
                        <Setter TargetName="Border" Property="Background"
                                Value="{StaticResource DisabledBackgroundBrush}" />
                        <Setter TargetName="Border" Property="BorderBrush"
                                Value="{StaticResource DisabledBorderBrush}" />
                        <Setter Property="Foreground"
                                Value="{StaticResource DisabledForegroundBrush}"/>
                        <Setter TargetName="Arrow" Property="Fill"
                                Value="{StaticResource DisabledForegroundBrush}" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <!-- Expander style -->
            <Style TargetType="Expander">
                <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Expander">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Name="ContentRow" Height="0"/>
                                </Grid.RowDefinitions>
                                <Border Name="Border" 
                                        Grid.Row="0" 
                                        Background="{StaticResource HeaderBrush}"                                        
                                        BorderBrush="{StaticResource NormalBorderBrush}"
                                        BorderThickness="1" 
                                        CornerRadius="4,4,0,0" >
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="20" />
                                        </Grid.ColumnDefinitions>
                                        <ToggleButton Grid.Column="1"
                                            IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,
                                            RelativeSource={RelativeSource TemplatedParent}}"
                                                      OverridesDefaultStyle="True" 
                                                      Template="{StaticResource ExpanderToggleButton}" 
                                                      Background="{StaticResource NormalBrush}" />
                                        <ContentPresenter Grid.Column="0"
                                                          Margin="4" 
                                                          ContentSource="Header" 
                                                          RecognizesAccessKey="True" />
                                    </Grid>
                                </Border>
                                <Border Name="Content" 
                                        Grid.Row="1" 
                                        Background="{StaticResource GroupBackgroundBrush}"
                                        BorderBrush="{StaticResource OpenGroupBorderBrush}" 
                                        BorderThickness="1,0,1,1" 
                                        CornerRadius="0,0,4,4" >
                                    <ContentPresenter Margin="4" />
                                </Border>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsExpanded" Value="True">
                                    <Setter TargetName="ContentRow" 
                                            Property="Height"
                                            Value="{Binding ElementName=Content,Path=DesiredHeight}" />
                                    <Setter TargetName="Border" Property="BorderBrush"
                                            Value="{StaticResource OpenHeaderBorderBrush}"/>
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter TargetName="Border" Property="Background"
                                            Value="{StaticResource DisabledBackgroundBrush}" />
                                    <Setter TargetName="Border" Property="BorderBrush"
                                            Value="{StaticResource DisabledBorderBrush}" />
                                    <Setter Property="Foreground"
                                            Value="{StaticResource DisabledForegroundBrush}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        
        <Style TargetType="{x:Type TabItem}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TabItem}">
                            <Grid>
                                <Border 
                                    Name="Border"
                                    Background="LightBlue"
                                    BorderBrush="Black" 
                                    BorderThickness="1,1,1,1" 
                                    CornerRadius="0,6,0,0">
                                    <ContentPresenter x:Name="ContentSite"
                                                      VerticalAlignment="Center"
                                                      HorizontalAlignment="Center"                                                  
                                                      ContentSource="Header"
                                                      Margin="12,2,12,2"/>                                
                                </Border>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter TargetName="Border" 
                                            Property="Background" Value="LightGray" />
                                </Trigger>
                                <Trigger Property="IsSelected" Value="False">
                                    <Setter TargetName="Border" Property="Background" Value="Transparent" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>



        <locala:TreeViewLineConverter x:Key="LineConverter"/>

        

        <!--=================================================================
      TreeViewItem
  ==================================================================-->
        <Style x:Key="ExpandCollapseToggleStyle" TargetType="ToggleButton">
            <Setter Property="Focusable" Value="False"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ToggleButton">
                        <Grid
              Width="15"
              Height="13"
              Background="White">
                            <Path x:Name="ExpandPath"
                HorizontalAlignment="Left"
                VerticalAlignment="Center"
                Margin="1,1,1,1"
                Fill="{StaticResource GlyphBrush}"
                Data="M 4 0 L 8 4 L 4 8 Z"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked"
                   Value="True">
                                <Setter Property="Data"
                    TargetName="ExpandPath"
                    Value="M 0 4 L 8 4 L 4 8 Z"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="TreeViewItemFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border>
                            <Rectangle Margin="0,0,0,0"
                     StrokeThickness="5"
                     Stroke="Black"
                     StrokeDashArray="1 2"
                     Opacity="0"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="{x:Type TreeViewItem}"
         TargetType="{x:Type TreeViewItem}">
            <Setter Property="Background"
          Value="Transparent"/>
            <Setter Property="HorizontalContentAlignment"
          Value="{Binding Path=HorizontalContentAlignment,
              RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
            <Setter Property="VerticalContentAlignment"
          Value="{Binding Path=VerticalContentAlignment,
              RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
            <Setter Property="Padding"
          Value="1,0,0,0"/>
            <Setter Property="Foreground"
          Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="FocusVisualStyle"
          Value="{StaticResource TreeViewItemFocusVisual}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition MinWidth="19"
                          Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>

                            <!-- Connecting Lines -->
                            <Rectangle x:Name="HorLn" Height="1" Stroke="#8888"  Margin="10,0,0,0" SnapsToDevicePixels="true"/>
                            <Rectangle x:Name="VerLn" Width="1" Stroke="#8888" Grid.RowSpan="2" SnapsToDevicePixels="true"/>
                            <ToggleButton x:Name="Expander"
                      Style="{StaticResource ExpandCollapseToggleStyle}"
                      IsChecked="{Binding Path=IsExpanded,
                              RelativeSource={RelativeSource TemplatedParent}}"
                      ClickMode="Press"/>
                            <Border Name="Bd"
                  Grid.Column="1"
                  Background="{TemplateBinding Background}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  Padding="{TemplateBinding Padding}">
                                <ContentPresenter x:Name="PART_Header"
                          ContentSource="Header"
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                            </Border>
                            <ItemsPresenter x:Name="ItemsHost"
                      Grid.Row="1"
                      Grid.Column="1"
                      Grid.ColumnSpan="2"/>
                        </Grid>
                        <ControlTemplate.Triggers>

                            <!-- This trigger changes the connecting lines if the item is the last in the list -->
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource LineConverter}}" Value="true">
                                <Setter TargetName="VerLn"
                    Property="Height"
                    Value="6"/>
                                <Setter TargetName="VerLn"
                    Property="VerticalAlignment"
                    Value="Top"/>
                            </DataTrigger>
                            <Trigger Property="IsExpanded"
                   Value="false">
                                <Setter TargetName="ItemsHost"
                    Property="Visibility"
                    Value="Collapsed"/>
                            </Trigger>
                            <Trigger Property="HasItems"
                   Value="false">
                                <Setter TargetName="Expander"
                    Property="Visibility"
                    Value="Hidden"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader"
                         Value="false"/>
                                    <Condition Property="Width"
                         Value="Auto"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header"
                    Property="MinWidth"
                    Value="75"/>
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader"
                         Value="false"/>
                                    <Condition Property="Height"
                         Value="Auto"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header"
                    Property="MinHeight"
                    Value="19"/>
                            </MultiTrigger>
                            <Trigger Property="IsSelected"
                   Value="true">
                                <Setter TargetName="Bd"
                    Property="Background"
                    Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                                <Setter Property="Foreground"
                    Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected"
                         Value="true"/>
                                    <Condition Property="IsSelectionActive"
                         Value="false"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="Bd"
                    Property="Background"
                    Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                                <Setter Property="Foreground"
                    Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                            </MultiTrigger>
                            <Trigger Property="IsEnabled"
                   Value="false">
                                <Setter Property="Foreground"
                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>
    <Grid Name="MainGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="500*"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Menu Grid.Row="0">
            <MenuItem Header="_File">
                <MenuItem Header="_Log-Off"/>
                <MenuItem Header="E_xit"/>
                <Separator></Separator>
                <MenuItem Header="_Import"/>
                <Separator></Separator>
                <MenuItem Header="_Database">
                    <MenuItem Header="_Back-up"/>
                    <MenuItem Header="_Restore"/>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="_Administration">
                <MenuItem Header="_Change Password"/>
            </MenuItem>
            <MenuItem Header="_Help"/>
        </Menu>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" MinWidth="150" />
                <ColumnDefinition Width="300*" MinWidth="150"/>
            </Grid.ColumnDefinitions>
            <Border Name="borderHeader" Grid.Column="0" BorderBrush="Gray" 
                BorderThickness="1" CornerRadius="0">
                <Grid Name="MainLeftGrid" HorizontalAlignment="Left" Margin="0,-2,0,2" >
                    <Grid.Resources>
                        <Style x:Key="buttonStyle" TargetType="{x:Type Button}">
                            <Setter Property="BorderThickness"  Value="0"/>
                            <Setter Property="BorderBrush"  Value="Black"/>
                            <Setter Property="Margin" Value="1,1,1,1"/>
                            <Setter Property="Background" Value="White"/>
                            <Style.Triggers>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter Property="Opacity" Value="0.30" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Grid.Resources>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"></RowDefinition>
                        <RowDefinition Height="auto"></RowDefinition>
                        <RowDefinition Height="auto"></RowDefinition>
                        <RowDefinition Height="auto"></RowDefinition>
                        <RowDefinition Height="auto"></RowDefinition>
                        <RowDefinition Height="auto"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Expander Grid.Row="0" Name="expanderAdministration">
                        <Expander.Header>
                            <BulletDecorator>
                                <BulletDecorator.Bullet>
                                    <Image Width="16" Source="images/main/application_view_tile.png"/>
                                </BulletDecorator.Bullet>
                                <TextBlock Margin="20,0,0,0">Administration</TextBlock>
                            </BulletDecorator>
                        </Expander.Header>

                        <TreeView Name="treeviewAdministration">

                            <TreeViewItem Header="General Settings" IsExpanded="True"  Name="AdminGeneralSettings">
                                <TreeViewItem Header="Account Policies" Name="AdminAccountPolicies"></TreeViewItem>
                                <TreeViewItem Header="Reader Settings" Name="AdminReaderSettings"></TreeViewItem>
                            </TreeViewItem>
                            <TreeViewItem Header="Accounts" IsExpanded="True"  Name="AdminAccounts">
                                <TreeViewItem Header="Users" Name="AdminUsers"></TreeViewItem>
                            </TreeViewItem>

                        </TreeView>
                    </Expander>
                    <Expander Grid.Row="1" Name="expanderSynch">
                        <Expander.Header>
                            <BulletDecorator>
                                <BulletDecorator.Bullet>
                                    <Image Width="16" Source="images/main/connect.png"/>
                                </BulletDecorator.Bullet>
                                <TextBlock Margin="20,0,0,0">Synchronise</TextBlock>
                            </BulletDecorator>
                        </Expander.Header>
                        <TreeView Name="treeviewSynch">
                            <TreeViewItem Header="Synchronise" Name="Synch"></TreeViewItem>
                        </TreeView>
                    </Expander>
                    <Expander Grid.Row="2" Name="expanderDataForms">
                        <Expander.Header>
                            <BulletDecorator>
                                <BulletDecorator.Bullet>
                                    <Image Width="16" Source="images/main/application_form.png"/>
                                </BulletDecorator.Bullet>
                                <TextBlock Margin="20,0,0,0">Data Forms</TextBlock>
                            </BulletDecorator>
                        </Expander.Header>
                        <TreeView Name="treeviewDataForms">

                            <TreeViewItem Header="Categories" Name="DataFormsCategories"/>
                            <TreeViewItem Header="Locations" Name="DataFormsLocations"/>
                            <TreeViewItem Header="Persons" Name="DataFormsPersons"/>
                            <TreeViewItem Header="Departments" Name="DataFormsDepartments"/>

                        </TreeView>
                    </Expander>
                    <Expander Grid.Row="3" Name="expanderItems">
                        <Expander.Header>
                            <BulletDecorator>
                                <BulletDecorator.Bullet>
                                    <Image Width="16" Source="images/main/application_key.png"/>
                                </BulletDecorator.Bullet>
                                <TextBlock Margin="20,0,0,0">Items</TextBlock>
                            </BulletDecorator>
                        </Expander.Header>
                        <TreeView Name="treeviewItems">
                            <TreeViewItem Header="Items" Name="Items" IsExpanded="True">
                            </TreeViewItem>
                        </TreeView>
                    </Expander>
                    <Expander Grid.Row="4" Name="expanderReports">
                        <Expander.Header>
                            <BulletDecorator>
                                <BulletDecorator.Bullet>
                                    <Image Width="16" Source="images/main/printer.png"/>
                                </BulletDecorator.Bullet>
                                <TextBlock Margin="20,0,0,0">Reports</TextBlock>
                            </BulletDecorator>
                        </Expander.Header>
                        <TreeView Grid.Row="0" Name="treeviewReports" >
                            <TreeViewItem Header="Asset" Name="tviAsset" IsExpanded="True">
                                <TreeViewItem Header="By RFID Number" Name="tviRFIDNumber" IsExpanded="True"></TreeViewItem>
                                <TreeViewItem Header="1.00 Book Value" Name="tviOneBookValue" IsExpanded="True"></TreeViewItem>
                                <TreeViewItem Header="Disposed Asset" Name="tviDisposedAsset" IsExpanded="True"></TreeViewItem>
                                <TreeViewItem Header="Leased Asset" Name="tviLeasedAsset" IsExpanded="True">
                                    <TreeViewItem Header="Lease end" Name="tviLeaseEnd" IsExpanded="True"></TreeViewItem>
                                    <TreeViewItem Header="On Lease" Name="tviOnLease" IsExpanded="True"></TreeViewItem>                                    
                                </TreeViewItem>
                                <TreeViewItem Header="Subsidiary Ledger" Name="tviSubsidiaryLedger" IsExpanded="True"></TreeViewItem>
                                <TreeViewItem Header="Warranty" Name="tviWarranty" IsExpanded="True">
                                    <TreeViewItem Header="Expired" Name="tviExpiredWarranty" IsExpanded="True"></TreeViewItem>
                                    <TreeViewItem Header="No warranty" Name="tviNoWarranty" IsExpanded="True"></TreeViewItem>
                                    <TreeViewItem Header="Under warranty" Name="tviUnderWarranty" IsExpanded="True"></TreeViewItem>
                                </TreeViewItem>
                            </TreeViewItem>
                            <TreeViewItem Header="Catalog" Name="tviCatalog" IsExpanded="True"></TreeViewItem>
                        </TreeView>
                    </Expander>
                    <Expander Grid.Row="5" Name="expanderSubLedger">
                        <Expander.Header>
                            <BulletDecorator>
                                <BulletDecorator.Bullet>
                                    <Image Width="16" Source="images/main/book_open.png"/>
                                </BulletDecorator.Bullet>
                                <TextBlock Margin="20,0,0,0">Subsidiary Ledger</TextBlock>
                            </BulletDecorator>
                        </Expander.Header>
                        <TreeView Grid.Row="0" Name="treeviewSubLedger">

                            <TreeViewItem Header="Department" Name="SubLedgerDepartment"/>
                            <TreeViewItem Header="Location" Name="SubLedgerLocation"/>
                            <TreeViewItem Header="Asset Classification" Name="SubLedgerAssetClassification"/>
                            <TreeViewItem Header="Leased Assets" Name="SubLedgerLeasedAssets"/>

                        </TreeView>
                    </Expander>
                </Grid>
            </Border>
            <Grid Grid.Column="1" Name="GridMainRight">
                
            </Grid>            
        </Grid>        
        <ToolBar Grid.Row="2">
            <Label>test</Label>
        </ToolBar>
    </Grid>
</Window>

    